#include <wx/app.h>
#include <wx/frame.h>
#include <wx/textctrl.h>

class MyApp : public wxApp
{
public:
    virtual bool OnInit();
};

class MyFrame : public wxFrame
{
public:
    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
private:
    wxTextCtrl* textCtrl;
};

bool MyApp::OnInit()
{
    MyFrame* frame = new MyFrame("Text Control Example", wxPoint(50, 50), wxSize(450, 340));
    frame->Show(true);
    return true;
}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
    : wxFrame(NULL, wxID_ANY, title, pos, size)
{
    Centre();
    
    textCtrl = new wxTextCtrl(this, wxID_ANY, wxEmptyString, wxPoint(20, 20), wxSize(400, 300), wxTE_MULTILINE);
    textCtrl->AppendText("This is a wxTextCtrl control\n");
    textCtrl->AppendText("You can type text here\n");
    textCtrl->AppendText("And you can copy and paste text\n");

    wxString str1 = wxT("Linux");
    wxString str2 = wxT("Operating");
    wxString str3 = wxT("System\n\n");
    wxString str = str1 + wxT(" ") + str2 + wxT(" ") + str3;

    textCtrl->AppendText(str);

    wxString str4 = wxT("The history of my life\n");
    textCtrl->AppendText(str4.MakeUpper());

    // long mem = wxGetFreeMemory().ToLong();
    // textCtrl->AppendText(wxString::Format(wxT("Free memory: %ld bytes.\n"), mem));

    // Formatting date and time
    wxDateTime now = wxDateTime::Now();
    wxString date1 = now.Format();
    wxString date2 = now.Format(wxT("%X"));
    wxString date3 = now.Format(wxT("%x"));

    textCtrl->AppendText(wxString::Format(wxT("Current date and time: %s\t, %s\t, %s\n"), date1, date2, date3));
}

wxIMPLEMENT_APP(MyApp);